package cn.easybuy.utils;

import cn.easybuy.entity.Product;

public class ShoppingCartItem {
	private Product product;//商品
	private Integer quantity;//商品的数量
	private float cost;//商品的小计价格

	public ShoppingCartItem(Product product, Integer quantity) {
		this.product = product;
		this.quantity = quantity;
		//根据商品的价格*数量 获取出商品的小计
		this.cost = product.getPrice() * quantity;
	}
	
	public Integer getQuantity() {
		return quantity;
	}
	//设置数量的时候 重新计算小计
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
		this.cost = product.getPrice() * quantity;
	}

	public Product getProduct() {
		return product;
	}

	public float getCost() {
		return cost;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public void setCost(float cost) {
		this.cost = cost;
	}
}
